OpenApi v3 refactor #3407
Conversation
|
I think we should make all the classes immutable. Mutability makes the code very hard to reason about, when there's so much going on. |
Indeed, many classes aren't good yet there are really at the POC state ^^. I think that the |
Definitely, it sounds like a great (and needed) design improvement. At some point we'll even maybe be able to provide a standalone OpenAPI component (a subtree split of this repo). |
9f443a0 to
04fdfaf
Compare
1187bd9 to
f41833c
Compare
e3035ba to
1c3c2dd
Compare
| } | ||
|
|
||
| /** | ||
| * @return array | array |
There was a problem hiding this comment.
array | array doesn't look right... maybe array[] was intended? or even array{array, array} (https://phpstan.org/writing-php-code/phpdoc-types#array-shapes)?
There was a problem hiding this comment.
indeed it should be array[]
There was a problem hiding this comment.
oh wait, I see that since then, $schemas has been changed from array to \ArrayObject... so that would give array{array, \ArrayObject} for PHPStan (or at this point maybe just remove this phpDoc?)
There was a problem hiding this comment.
actually the return has become useless, see #4199
| return 0 === strpos($operation['path'], '/') ? $operation['path'] : '/'.$operation['path']; | ||
| } | ||
| $path = $this->operationPathResolver->resolveOperationPath($resourceShortName, $operation, $operationType, $operationName); | ||
| if ('.{_format}' === substr($path, -10)) { |
There was a problem hiding this comment.
Hey @soyuka Does there any way to enable defining '.{_format}' per resource, even ApiPlatform\Core\OpenApi\Model\Paths does not contain a setter function, in case we decide to decorate the OpenapiFactory ? I have a resource that should export pdf and docx.
Cheers!
With this rework, I want to improve the developer experience in enhancing our OpenAPI support. By using explicit classes that matches the OpenAPI spec, it should be easier to:
Note that there are some missing features (for example pagination parameters and components) and I wanted to get back some feedbacks before continuing this work as it's a heavy refactor.
I also want to add two new objects (PaginationOptions, OpenApiAuthentificationOptions) to reduce the number of arguments in the constructor.
WDYT ? Should I continue working on this?